<%--
  User: Sujan
  Date: Jun 14, 2007
  Time: 4:59:46 PM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<html:html locale="true">
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
    <HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script language='javascript'>
    function refreshParentWindowListData()
    {
        var parentForm = window.opener.QuotationForm;
        var listCtrl;
        <logic:present name="refreshListData">
            <logic:equal value="QuoteType" name="quotePopupFieldsForm" property="title">
                listCtrl = parentForm.quoteType;
                window.opener.deleteAllListOptions(listCtrl);
                window.opener.addOptionToList ( listCtrl, "--- Select ---" , "-1" );
                <logic:iterate id="field" name="quotePopupFieldsForm" property="fieldsList" type="com.scalar.chiptrack.sales.QuotePopupField">
                    <logic:equal value="false" name="field" property="disabled">
                        window.opener.addOptionToList ( listCtrl, '<bean:write name="field" property="name"/>' , '<bean:write name="field" property="name"/>' );
                    </logic:equal>
                </logic:iterate>
                window.opener.addOptionToList ( listCtrl, "--- Edit ---" , "-2" );
            </logic:equal>
            <logic:equal value="QuoteApplication" name="quotePopupFieldsForm" property="title">
                listCtrl = parentForm.application;
                window.opener.deleteAllListOptions(listCtrl);
                window.opener.addOptionToList ( listCtrl, "--- Select ---" , "-1" );
                <logic:iterate id="field" name="quotePopupFieldsForm" property="fieldsList" type="com.scalar.chiptrack.sales.QuotePopupField">
                    <logic:equal value="false" name="field" property="disabled">
                        window.opener.addOptionToList ( listCtrl, '<bean:write name="field" property="name"/>' , '<bean:write name="field" property="name"/>' );
                    </logic:equal>
                </logic:iterate>
                window.opener.addOptionToList ( listCtrl, "--- Add New ---" , "-2" );
            </logic:equal>
        </logic:present>
    }
    function save()
    {
        var form = document.quotePopupFieldsForm;
        var errors = '';
        var fieldName = form.fieldName.value;
        if( fieldName.trim() == '')
        {
            errors = errors + "<li> Please enter <bean:write name="quotePopupFieldsForm" property="title"/>";
        }
        if(errors != '')
        {
            var inf = document.getElementById("infoMessagesId");
            inf.innerHTML = '';
            var err = document.getElementById("errorMessagesId");
            err.innerHTML = '';
            var pa=document.getElementById("errors");
            pa.innerHTML = errors;
            return false;
        }
        form.fieldName.value = form.fieldName.value.trim();
        form.action = '<%=chipTracContext%>/quotePopupFieldsAction.do?action=save<bean:write name="quotePopupFieldsForm" property="title"/>';
        return true;
    }
    function reset()
    {
        document.quotePopupFieldsForm.reset();
    }
    function closeWindow(form)
    {
        window.close();
    }
    function showErrorReportPage()
    {
        newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
        newWindow.focus();
    }
</script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<body bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="refreshParentWindowListData()">
<%
    String isSessionExpired = (String)request.getAttribute( "isSessionExpired" );
    if ( !"true".equalsIgnoreCase( isSessionExpired ) )
    {
%>
    <html:form name="quotePopupFieldsForm" type="com.scalar.chiptrack.sales.forms.quote.QuotePopupFieldsForm" action='/quotePopupFieldsAction.do' onsubmit="javascript:return save();" scope="request">
        <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
        <center><span class="NArialW"><nested:write property="title"/></span></center>
        <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
        <table border="0" width="90%" align=center>
            <tr>
                <td>
                    <table border="0" width="100%" cellspacing='10' cellpadding='2' align='center'>
                        <tr><td colspan=2 align=right><a href="javascript:closeWindow(document.quotePopupFieldsForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true" ><font class='NArialL'>Close this window</font></a></td></tr>
                        <tr><td colspan='2' id="errorMessagesId"><chiptrack:errors styleClass='NArialL' /></td></tr>
                        <tr><td colspan='2' id="infoMessagesId"><chiptrack:info styleClass='NArialL' /></td></tr>
                        <tr><td colspan='2' class="NArialL"><FONT id="errors" color='red'></FONT></td></tr>
	                    <tr>
                            <td colspan='2' nowrap><font class="NArialL"><nested:write property="title"/> Name:&nbsp;&nbsp;</font>
			                    <nested:text property="fieldName" size="25" maxlength="25" styleClass="txfield"/>
                                <nested:hidden property="id"/>
                            </td>
                        </tr>
	                    <tr>
                            <td colspan='1' nowrap align='center'>
                                <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Save';return true" onmouseout="window.status='';return true" title="Click here to Save">
	                        </td>
		                    <td colspan='1' nowrap align='left'>
		                        <a href="javascript:reset()" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
	                        </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table border="0" width="100%" bordercolor="#FFFFFF" align='center'>
                        <tr>
                            <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><nested:write property="title"/></font></font></td>
                            <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></font></td>
                        </tr>
                        <nested:iterate id="field" indexId="idx" property="fieldsList" type="com.scalar.chiptrack.sales.QuotePopupField">
                            <tr bgcolor="<%=idx.intValue()%2==0 ? "#DEE1E2" : "#FFFFEE" %>">
                                <td nowrap width="15%" align="left" class="NArialL"><nested:write property="name" /></td>
                                <td nowrap width="15%" align="center" class="NArialL">
                                    <nested:equal property="disabled" value="true">
                                        <a href='<%=chipTracContext%>/quotePopupFieldsAction.do?action=activate<nested:write property="/title"/>&id=<nested:write property="id"/>'><font color='red'> Activate</font></a>&nbsp;&nbsp;
                                    </nested:equal>
                                    <nested:equal property="disabled" value="false">
                                        <a href='<%=chipTracContext%>/quotePopupFieldsAction.do?action=disable<nested:write property="/title"/>&id=<nested:write property="id"/>'> Disable</a>&nbsp;&nbsp;
                                    </nested:equal>
                                    <a href='<%=chipTracContext%>/quotePopupFieldsAction.do?action=edit<nested:write property="/title"/>&id=<nested:write property="id"/>&fieldName=<nested:write property="name"/>'>Edit</a>
                                </td>
                            </tr>
                        </nested:iterate>
                        <tr><td class="NArialL" colspan=5><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=50></td></tr>
                        <tr><td colspan=3 align=center><a href="javascript:closeWindow(document.quotePopupFieldsForm);" onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'>Close this window</font></a></td></tr>
                    </table>
                </td>
            </tr>
        </table>
    </html:form>
<%
    }
    else
    {
%>
        <table cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
            <tr>
                <td>
                    <table align="center" border="0" width="40%" bgcolor="#FDF5E6">
                        <tr><td>&nbsp;</td></tr>
                        <tr><td align="center" ><font class="NArialL" ><font color="red">Session has been time out , Please close this window and login again.</font></font></td></tr>
                        <tr><td>&nbsp;</td></tr>
                        <tr><td align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></td></tr>
                    </table>
                </td>
           </tr>
           <tr><td>&nbsp;</td></tr>
        </table>
<%
    }
%>
</body>
</html:html>